﻿#region Copyright (C) Sector7 Software Studio. All rights reserved
/*******************************************************************************************
 * Creation
 *      Author:         Mac
 *      Date:           2013/8/12 20:44:51
 *      Version:        
 * Modification 
 *      Author: 
 *      Date: 
 *      Description: 
 *      Version:
 *******************************************************************************************/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using Sector7.Framework.DB;
using Sector7.Medical.EntityType;

namespace Sector7.Medical.DAO.Standard
{
    /// <summary>
    /// <!-- The description about this class. -->
    /// </summary>
    public class RecipeItemDAO : DAOBase<M7_RecipeItem>, IRecipeItemDAO
    {
        #region Public functions
        /// <summary>
        /// 
        /// </summary>
        /// <param name="recipeItem"></param>
        /// <returns></returns>
        public override object Create(M7_RecipeItem recipeItem)
        {
            string sql = @"
                INSERT INTO M7_RecipeItem
                        (RecipeId
                        ,DrugId
                        ,Number
                        ,UsageNumber
                        ,FrequencyId
                        ,ApproachId)
                    VALUES
                        (@RecipeId
                        ,@DrugId
                        ,@Number
                        ,@UsageNumber
                        ,@FrequencyId
                        ,@ApproachId)";

            using (DBHelper helper = new DBHelper())
            {
                return helper.ExecuteScalar(sql,
                    DBUtil.CreateSqlParameter(recipeItem.RecipeId, "RecipeId"),
                    DBUtil.CreateSqlParameter(recipeItem.DrugId, "DrugId"),
                    DBUtil.CreateSqlParameter(recipeItem.Number, "Number"),
                    DBUtil.CreateSqlParameter(recipeItem.UsageNumber, "UsageNumber"),
                    DBUtil.CreateSqlParameter(recipeItem.FrequencyId, "FrequencyId"),
                    DBUtil.CreateSqlParameter(recipeItem.ApproachId, "ApproachId"));
            }
        }
        #endregion
    }
}
